/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package shoppinglist;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import shoppinglist.Controller;

/**
 *
 * @author Student
 */
public class ButtonPanel extends JPanel  {
    BufferedImage img;
    Controller controller;
    private JTextField Amount = new JTextField(5);
    


    public ButtonPanel(Controller controller){ 
        setPreferredSize( new Dimension( 20, 10 ) );
        String keyPress;
        this.controller=controller;
        setButtons();
        try {
            img = ImageIO.read(new File("src/resources/shop.jpg"));
        } catch (IOException ex) {
            Logger.getLogger(ButtonPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        // paint the background image and scale it to fill the entire space
        g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
    }

    private void setButtons() {
        ButtonListener buttonListener = new ButtonListener(this);
        //System.out.println("");
        FlowLayout flow = new FlowLayout();
        setLayout(flow);
        JButton AddButton = new JButton("Add");
        AddButton.setFont(new Font("Arial", Font.BOLD, 14));
        add(AddButton);
        AddButton.addActionListener(buttonListener);
        JButton Save = new JButton("Save");
        Save.setFont(new Font("Arial", Font.BOLD, 14));
        add(Save);
        Save.addActionListener(buttonListener);
        JButton Open = new JButton("Open");
        Open.setFont(new Font("Arial", Font.BOLD, 14));
        add(Open);
        Open.addActionListener(buttonListener);
        JButton Update = new JButton("Update");
        Update.setFont(new Font("Arial",Font.BOLD,14));
        add(Update);
        Update.addActionListener(buttonListener);        
        getAmount().setFont(new Font("Arial", Font.BOLD, 14));
        add(getAmount());
        getAmount().addActionListener(buttonListener);
        
    }

    /**
     * @return the Amount
     */
    public JTextField getAmount() {
        return Amount;
    }

    
    

}
